import os
import sys
import importlib

_ = os.path.abspath(os.path.dirname(__file__))  # 返回当前文件路径
root_path = os.path.abspath(os.path.join(_, '../../'))  # 返回根目录文件夹
sys.path.append(root_path)

proxy = {
    # 'http': '127.0.0.1:7890',
    # 'https': '127.0.0.1:7890',
}

exchange_basic_config = {
    'timeout': 30000,
    'rateLimit': 30,
    'enableRateLimit': False,
    'options': {
        'adjustForTimeDifference': True,
        'recvWindow': 10000,
    },
    'proxies': proxy,
}

def get_exchange_by_account(account_name):
    account_path = os.path.join(root_path, f'secret/{account_name}.py')
    if os.path.exists(account_path):
        binance_secret = importlib.import_module(f'secret.{account_name}')
    else:
        binance_secret = importlib.import_module(f'secret.example')
    apiKey = binance_secret.apiKey
    secret = binance_secret.secret
    return {
        'apiKey': apiKey,
        'secret': secret,
    }
